<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2021/12/16
 * Time: 10:28
 */
if (!empty($_POST['user_name'])&&!empty($_POST['user_pwd'])){
    $user_name=$_POST['user_name'];
    $user_pwd=$_POST['user_pwd'];
}
session_start();
if(isset($_COOKIE['taken'])){
    $key=$_COOKIE['taken'];
}
if(!empty($_SESSION[$key])){
    $user_name=$_SESSION[$key]['user_name'];
    $user_pwd=$_SESSION[$key]['user_pwd'];
}

if($user_name=='admin'&&$user_pwd=='123456'){
    echo '欢迎:'.$user_name.'<br/>';
    echo '<a href="../open/open_card.php">执行开卡操作</a><br/>';
    echo '<a href="../open/open_account.php">执行开户操作</a><br/>';
    echo '<a href="../user/user_info.php">用户列表</a><br/>';
    setcookie('taken',md5($user_name.$user_pwd.time()),time()+3600,'/');
    $_SESSION[md5($user_name.$user_pwd.time())]=[
        'user_name'=>$user_name,
        'user_pwd'=>$user_pwd
    ];
}
else{
    echo '用户名或者密码错误，请重新登陆<a href="admin_login.php">返回</a>';
}